package com.kimoge.spring6.validation.methodone;

import org.springframework.validation.BindingResult;
import org.springframework.validation.DataBinder;
import org.springframework.validation.Validator;

/**
 * @author kimoge
 * @date 2025/8/30
 * @description
 */
public class TestDemo {
    public static void main(String[] args) {
        Person person = new Person(null,-1 , "未知");

        DataBinder dataBinder = new DataBinder(person);
        dataBinder.setValidator(new PersonValidator());
        dataBinder.validate();

        //输出结果
        BindingResult bindingResult = dataBinder.getBindingResult();
        bindingResult.getAllErrors().forEach(System.out::println);
    }
}
